let api_config = {
	list: {
		url: "",
		action: 'product_getList',
		method: "get"
	},
	add: {
		url: "",
		action: "product_save",
		method: "get"
	},
	edit: {
		url: "",
		action: "product_save",
		method: "get",
		id_field: "id",
		is_query_detail: false
	},
	delete: {
		url: "",
		action: "product_delProduct",
		method: "get",
		id_field: "id",
	},
	detail: {
		url: "",
		action: "product_info",
		method: "get",
		id_field: "id",
	},
}


let column_params = {
	"id": "",
	"title": "",
	"subtitle": "",
	"formfileds": "",
	"brandId": "",
	"channelId": "",
	"ordering": "",
	"units": "",
	"keywords": "",
	"tags": "",
	"thumb": "",
	"images": "",
	"videoImg": "",
	"videoUrl": "",
	"cont1": "",
	"cont2": "",
	"cont3": "",
	"cont4": "",
	"cardForbidPlace":"",//禁发地区
	"provinceIds":"",
	"filesIds":"",
	"cardBelongPlace":"",//归属地
	"table_width": "auto",
	"cardFirstRecharge":"",//首充
	"cardVoiceStr":"",//语音
	"cardYearStart":"",//最大年龄
	"cardLongTerm":"",//是否长期卡：0-非长期 1-长期
	"ifChargePic":"",//是否上传充值截图
	"cardMonthRent":"",//卡月租
	"yunfeiMoban": "",
	"description": "",
	"shareImg": "",
	"isTuan": "",
	"tuanNum": "",
	"inventorys": "",
}


let columns = [{
	"sort_in_form": "",
	"field": "id",
	"field_title": "ID",
	"table_width": "80",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": false,
	"is_hidden_in_form": true,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "productInfo",
	"field_title": "商品信息",
	"table_width": "auto",
	"table_render_type": "img-text",
	"form_render_type": "input",
	"is_hidden_in_table": false,
	"is_hidden_in_form": true,
	"is_required_in_form": false,
},
{
	"sort_in_form": "",
	"field": "title",
	"field_title": "商品名称",
	"table_width": "250",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": true
},
{
	"sort_in_form": "",
	"field": "thumb",
	"field_title": "列表缩略图",
	"table_width": "auto",
	"table_render_type": "image",
	"form_render_type": "image",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "formfileds",
	"field_title": "字段(身份证号|收货城市|详细地址)",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false,
},
{
	"sort_in_form": "",
	"field": "subtitle",
	"field_title": "副标题",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false,
},
{
	"sort_in_form": "",
	"field": "jianjie",
	"field_title": "简介",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "textarea",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "channelId",
	"field_title": "商品分类",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "treeSelectForProductCategory",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "channelTitle",
	"field_title": "商品分类",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": false,
	"is_hidden_in_form": true,
	"is_required_in_form": false
},{
	"sort_in_form": "",
	"field": "provinceName",
	"field_title": "发卡省份",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": false,
	"is_hidden_in_form": true,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "status",
	"field_title": "商品状态",
	"table_width": "80",
	"table_render_type": "tag",
	"form_render_type": "radio",
	"is_hidden_in_table": false,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "channelIdArr",
	"field_title": "分类数组",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": true,
	"is_hidden_in_form": true,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "brandId",
	"field_title": "运营商",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "treeSelect",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},

{
	"sort_in_form": "",
	"field": "filesIds",
	"field_title": "上传图片设置",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "treeSelectForFiledsIds",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "ifChargePic",
	"field_title": "上传充值成功图",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "radio",
	"is_hidden_in_table": false,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},

{
	"sort_in_form": "",
	"field": "brand",
	"field_title": "运营商名称",
	"table_width": "140",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": false,
	"is_hidden_in_form": true,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "ordering",
	"field_title": "排序",
	"table_width": "80",
	"table_render_type": "text",
	"form_render_type": "input",
	"column_sortable": true,
	"is_hidden_in_table": false,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "units",
	"field_title": "单位",
	"table_width": "80",
	"table_render_type": "text",
	"form_render_type": "select",
	"is_hidden_in_table": false,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "keywords",
	"field_title": "关键词",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "tags",
	"field_title": "标签",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "select",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "images",
	"field_title": "主图",
	"table_width": "auto",
	"table_render_type": "image-list",
	"form_render_type": "image-list",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "videoImg",
	"field_title": "视频主图",
	"table_width": "auto",
	"table_render_type": "image",
	"form_render_type": "image",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "videoUrl",
	"field_title": "视频链接",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "cont1",
	"field_title": "商品详情",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "richtext",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "cont2",
	"field_title": "套餐详情",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "richtext",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
  "field": "cont3",
  "field_title": "优惠详情",
	"table_width": "auto",
  "table_render_type": "text",
  "form_render_type": "richtext",
  "is_hidden_in_table": true,
  "is_hidden_in_form": false,
  "is_required_in_form": false
},
{
"sort_in_form": "",
 "field": "cont4",
 "field_title": "结算规则",
"table_width": "auto",
 "table_render_type": "text",
 "form_render_type": "richtext",
 "is_hidden_in_table": true,
 "is_hidden_in_form": false,
 "is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "provinceIds",
	"field_title": "发卡省份",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "treeSelectForProvince",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "cardForbidPlace",
	"field_title": "禁发地区",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
/* {
	"sort_in_form": "",
	"field": "provinceIds",
	"field_title": "发卡省份",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "select",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false,
	"multiple":true,
}, */
{
	"sort_in_form": "",
	"field": "cardBelongPlace",
	"field_title": "归属地",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "cardFirstRecharge",
	"field_title": "首充",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "cardVoiceStr",
	"field_title": "语音",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "cardYearStart",
	"field_title": "办理最大年龄",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "cardLongTerm",
	"field_title": "是否长期卡",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "radio",
	"is_hidden_in_table": false,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, 
{
	"sort_in_form": "",
	"field": "cardMonthRent",
	"field_title": "卡月租",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": 250,
	"is_hidden_in_form": false,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "yunfeiMoban",
	"field_title": "运费模板",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "select",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "description",
	"field_title": "商品简介",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "textarea",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, {
	"sort_in_form": "",
	"field": "shareImg",
	"field_title": "商品分享海报图",
	"table_width": "auto",
	"table_render_type": "image",
	"form_render_type": "image",
	"is_hidden_in_table": true,
	"is_hidden_in_form": false,
	"is_required_in_form": false
}, /* {
	"sort_in_form": "",
	"field": "isTuan",
	"field_title": "是否拼团",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "radio",
	"is_hidden_in_table": true,
	"is_hidden_in_form": true,
	"is_required_in_form": false
}, */ {
	"sort_in_form": "",
	"field": "tuanNum",
	"field_title": "拼团人数",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": true,
	"is_hidden_in_form": true,
	"is_required_in_form": false
},
{
	"sort_in_form": "",
	"field": "inventorys",
	"field_title": "规格参数",
	"table_width": "auto",
	"table_render_type": "text",
	"form_render_type": "input",
	"is_hidden_in_table": true,
	"is_hidden_in_form": true,
	"is_required_in_form": false
}]

let table_columns = columns.filter(v => !v.is_hidden_in_table).map(v => ({
	...v
}))
// [
//     // {
//     //     column: "postId",//字段属性名
//     //     field_title: "ID", //字段标题
//     //     table_width: "auto",//表格宽度
//     //     column_sortable: false, //表格是否可排序
//     //     column_show_overflow_tooltip: false, //表格悬浮是否展示提示
//     //     table_render_type: '',//表格展示类型   '' || text || tag || image || image-list || file
//     // },
// ]

let form_fields = columns.filter(v => !v.is_hidden_in_form).map(v => ({
	...v
}))

// 表单默认值
let form_fields_default_value = {
	// "id": "",
	// "title": "",
	// "subtitle": "",
	// "brandId": "",
	// "channelId": "",
	// "ordering": "",
	// "units": "",
	// "keywords": "",
	// "tags": "",
	// "thumb": "",
	// "images": "",
	// "videoImg": "",
	// "videoUrl": "",
	// "cont1": "",
	// "cont2": "",
	// "cont3": "",
	// "yunfeiMoban": "",
	// "description": "",
	// "shareImg": "",
	"cardLongTerm":0,
	"ifChargePic":0,
	"isTuan": 0,
	"status": 1,
	// "tuanNum": "",
	// "inventorys": "",
}

// [
//     //【form_render_type 类型列表】
//     //input 默认
//     //number 文字输入
//     //textarea 文本域
//     //date 日期
//     //select 下拉选
//     //radio 单选
//     //cascader 级联选择
//     //upload-image 上传图片
//     //upload-file 上传文件
//     //rich-editor 富文本编辑器
//     //topic-card 话题卡片
//     {
//         column: "postId",
//         field_title: "ID",
//         is_required: 1,
//         form_render_type: "ID", //'' || text || tag || image || image-list || file
//         //选项型数据
//         // labelKey: "channelName",
//         // valueKey: "channelId",
//         // options: newsTypeOptions,

//         // 文件上传
//         // upload_multiple: true,
//         // upload_limit: 9,
//         // upload_tip: "(可上传多图，建议图片压缩后上传)",
//         // cache_key: "upload_cover_list", //图片上传回显
//         // saveFormat: "jsonObjectArray",
//     },
// ]


// console.log('字段配置 columns', JSON.parse(JSON.stringify(columns)))
console.log('表格配置 table_columns', JSON.parse(JSON.stringify(table_columns)))
console.log('表单配置 form_fields', JSON.parse(JSON.stringify(form_fields)))

// console.log('字段配置 columns', (JSON.stringify(columns)))
// console.log('表格配置 table_columns', (JSON.stringify(table_columns)))
// console.log('表单配置 form_fields', (JSON.stringify(form_fields)))




let table_row_actions = [
	{
		title: '编辑',
	},
	{
		title: '删除',
	},
	{
		title: '下架',
		condition: { //展示条件
			field: 'status',
			field_value: 1,
		},
	},
	{
		title: '上架',
		condition: { //展示条件
			field: 'status',
			field_value: -1,
		},
	},
	/* {
		title: '复制链接',
	}, */
]



let radio_options_map = {
	cardLongTerm: [
		{
			title: '非长期',
			value: 0,
			type: 'feichangqi',
		},
		{
			title: '长期',
			value: 1,
			type: 'changqi',
		},
	],
	ifChargePic: [
		{
			title: '否',
			value: 0,
			type: 'no',
		},
		{
			title: '是',
			value: 1,
			type: 'yes',
		},
	],
	
	/* isTuan: [
		{
			title: '否',
			value: 0,
			type: '',
		},
		{
			title: '是',
			value: 1,
			type: 'info',
		},
	], */
	status: [
		{
			title: '售卖中',
			value: 1,
			type: 'success',
		},
		{
			title: '已下架',
			value: -1,
			type: 'warning',
		},
	],
}


let select_config_map = {
	'tags': {
		options: [],
		labelKey: 'title',
		valueKey: 'title',
	},
	'units': {
		api: {
			url: '/admin_service.php',
			method: 'get',
			data: {
				action: 'product_getUnitList',
				page: 1,
				pageNum: 100,
			},
		},
		resHasPagination: true,
		options: [],
		labelKey: 'title',
		valueKey: 'title',
	},
	'provinceIds':{
		list:[
			{id: 111, title: "北京", parentId: 0, code: 111},
			{id: 112, title: "天津", parentId: 0, code: 112},
			{id: 113, title: "河北省", parentId: 0, code: 113},
			{id: 114, title: "山西省", parentId: 0, code: 114},
			{id: 115, title: "内蒙古省", parentId: 0, code: 115},
			{id: 121, title: "辽宁省", parentId: 0, code: 121},
			{id: 122, title: "吉林省", parentId: 0, code: 122},
			{id: 123, title: "黑龙江省", parentId: 0, code: 123},
			{id: 131, title: "上海省", parentId: 0, code: 131},
			{id: 132, title: "江苏省", parentId: 0, code: 132},
			{id: 133, title: "浙江省", parentId: 0, code: 133},
			{id: 134, title: "安徽省", parentId: 0, code: 134},
			{id: 135, title: "福建省", parentId: 0, code: 135},
			{id: 136, title: "江西省", parentId: 0, code: 136},
			{id: 137, title: "山东省", parentId: 0, code: 137},
			{id: 141, title: "河南省", parentId: 0, code: 141},
			{id: 142, title: "湖北省", parentId: 0, code: 142},
			{id: 143, title: "湖南省", parentId: 0, code: 143},
			{id: 144, title: "广东省", parentId: 0, code: 144},
			{id: 145, title: "广西省", parentId: 0, code: 145},
			{id: 146, title: "海南省", parentId: 0, code: 146},
			{id: 150, title: "重庆省", parentId: 0, code: 150},
			{id: 151, title: "四川省", parentId: 0, code: 151},
			{id: 152, title: "贵州省", parentId: 0, code: 152},
			{id: 153, title: "云南省", parentId: 0, code: 153}, 
			{id: 154, title: "西藏省", parentId: 0, code: 154}, 
			{id: 161, title: "陕西省", parentId: 0, code: 161},
			{id: 162, title: "甘肃省", parentId: 0, code: 162},
			{id: 163, title: "青海省", parentId: 0, code: 163},
			{id: 164, title: "宁夏省", parentId: 0, code: 164},
			{id: 165, title: "新疆省", parentId: 0, code: 165},
			{id: 171, title: "台湾省", parentId: 0, code: 171},
			{id: 172, title: "香港省", parentId: 0, code: 172},
			{id: 173, title: "澳门省", parentId: 0, code: 173}
		],
		options: [],
		labelKey: 'title',
		valueKey: 'id',
	},
	'filesIds': {
		api: {
			url: '/admin_service.php',
			method: 'get',
			data: {
				action: 'setting_getFiles',
			},
		},
		resHasPagination: true,
		options: [],
		labelKey: 'title',
		valueKey: 'id',
	},
	'yunfeiMoban': {
		api: {
			url: '/admin_service.php',
			method: 'get',
			data: {
				action: 'yunfei_getList',
				page: 1,
				pageNum: 100,
			},
		},
		resHasPagination: true,
		options: [],
		labelKey: 'title',
		valueKey: 'id',
	},

}


let tree_config_map = {
	'channelId': {
		api: {
			url: '/admin_service.php',
			method: 'get',
			data: {
				action: 'product_getProductChannelList',
				page: 1,
				pageNum: 100,
				position: 0
			},
		},
		treeData: [],
		treeProps: {
			label: "title",
			children: "child",
		},
		treeShowCheckbox: false,
		treeNodeKey: "id",
		defaultExpandAll: true,
		titleKey: 'channelTitle',
		resHasPagination: true, //是否存在分页

		//
		treeShowCheckbox: true,//产品允许多选
	},
	'provinceIds': {
		api: {
			url: '/admin_service.php',
			method: 'get',
			data: {
				action: 'setting_getArea',
				parentId: 0,
			},
		},
		treeData: [],
		treeProps: {
			label: "name",
			//children: "child",
		},
		treeShowCheckbox: true,
		treeNodeKey: "id",
		defaultExpandAll: true,
		titleKey: 'provinceName',
		resHasPagination: false, //是否存在分页
	},
	'filesIds': {
		api: {
			url: '/admin_service.php',
			method: 'get',
			data: {
				action: 'setting_getFiles',
			},
		},
		treeData: [],
		treeProps: {
			label: "title",
			//children: "child",
		},
		treeShowCheckbox: true,
		treeNodeKey: "id",
		defaultExpandAll: true,
		titleKey: 'filesName',
		resHasPagination: false, //是否存在分页
	},
	'brandId': {
		api: {
			url: '/admin_service.php',
			method: 'get',
			data: {
				action: 'product_getProductBrandList',
				page: 1,
				pageNum: 100,
				position: 0
			},
		},
		treeData: [],
		treeProps: {
			label: "title",
			children: "child",
		},
		treeShowCheckbox: false,
		treeNodeKey: "id",
		defaultExpandAll: true,
		titleKey: 'brandTitle',
		resHasPagination: true, //是否存在分页
	}
}






// 上传配置
let upload_config_map = {
	'thumb': {
		multiple: false,
		limit: 1,
		tip: '请选择文件',
	},
	'images': {
		multiple: true,
		limit: 100,
		tip: '请选择文件',
	},
	'videoImg': {
		multiple: false,
		limit: 1,
		tip: '请选择文件',
	},
	'shareImg': {
		multiple: false,
		limit: 1,
		tip: '请选择文件',
	},
}


let form_field_multiple_map = {
	'tags': true,
	'provinceIds':true,
	'filesIds':true
}


export default {
	api_config,
	table_columns,
	form_fields,
	form_fields_default_value,
	table_row_actions,
	radio_options_map,
	select_config_map,
	upload_config_map,
	tree_config_map,
	form_field_multiple_map,
};